﻿using System;
using System.Collections.Generic;
using System.Text;

namespace RaisingStudio.Data.Common
{
    /// <summary>
    /// Column definition.
    /// </summary>
    [Serializable]    
    public class DataColumnDefinition
    {
        private string columnName;
        /// <summary>
        /// Column name.
        /// </summary>
        public string ColumnName
        {
            get
            {
                return this.columnName;
            }
            set
            {
                this.columnName = value;
            }
        }

        private string sourceName;
        /// <summary>
        /// The name in database.
        /// </summary>
        public string SourceName
        {
            get
            {
                return this.sourceName;
            }
            set
            {
                this.sourceName = value;
            }
        }

        private bool allowDBNull = true;
        /// <summary>
        /// A value that indicates whether null values are allowed in this column for rows that belong to the table.
        /// </summary>
        public bool AllowDBNull
        {
            get
            {
                return this.allowDBNull;
            }
            set
            {
                this.allowDBNull = value;
            }
        }

        private bool autoIncrement = false;
        /// <summary>
        /// A value that indicates whether the column automatically increments the value of the column for new rows added to the table.
        /// </summary>
        public bool AutoIncrement
        {
            get
            {
                return this.autoIncrement;
            }
            set
            {
                this.autoIncrement = value;
            }
        }

        private System.Data.DbType dbType = System.Data.DbType.String;
        /// <summary>
        /// Gets or sets DbType。
        /// </summary>
        public System.Data.DbType DbType
        {
            get
            {
                return this.dbType;
            }
            set
            {
                this.dbType = value;
            }
        }

        private bool isPrimaryKey;
        public bool IsPrimaryKey
        {
            get { return isPrimaryKey; }
            set { isPrimaryKey = value; }
        }

        
        #region Constructor
        public DataColumnDefinition()
        {

        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="sourceName">The name in database.</param>
        public DataColumnDefinition(string columnName, string sourceName)
        {
            this.columnName = columnName;
            this.sourceName = sourceName;
        }
        #endregion
    }
}
